package com.example;

import lombok.SneakyThrows;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
 * @Author: Hanko
 * @Date: 2022-2-9 14:25
 */
public class HttpClient {

    @SneakyThrows
    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            get();
            TimeUnit.SECONDS.sleep(5);
        }

    }

    static void get(){
        String url = "https://zhuanlan.zhihu.com/p/466135263";
        CloseableHttpResponse responseBody = null;
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        try {
            responseBody = httpclient.execute(httpPost);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("responseBody = " + responseBody);
    }
}
